<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title>01_注册全局组件</title>
  <!-- 引入Vue -->
  <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
  <!-- 准备好一个容器-->
  <div id="demo">
  </div>
</body>

<script type="text/javascript">
  //阻止 vue 在启动时生成生产提示。
  Vue.config.productionTip = false;

  // 创建School组件
  const School = Vue.extend({
    name: 'School',
    template: `
      <div>
        <h2>学校名称:{{schoolName}}</h2>
          <h2>学校地址:{{schoolAddress}}</h2>
        </div>
    `,
    data() {
      return {
        schoolName: '尚硅谷',
        schoolAddress: '北京',

      }
    },
  })

  // 创建Person组件
  const Person = Vue.extend({
    name: 'School',
    template: `
      <div>
        <h2>人员名称:{{PersonName}}</h2>
          <h2>人员年龄:{{PersonAge}}</h2>
        </div>
    `,
    data() {
      return {
        PersonName: '马志强',
        PersonAge: 48,

      }
    },
  })

  // 全局注册
  Vue.components('Person', Person)

  // 创建App组件
  const App = Vue.extend({
    name: 'App',
    template: `
      <div>  
        <School></School>
        </hr>
        <Person></Person>
        </div>
    `,
    components: { School, } //局部注册
  })


  new Vue({
    el: '#demo',
    template: `<App />`,
    components: { App }
  })
</script>

</html>